use moyu;
use core::{ convert::TryFrom };

fn main() {
    let mut packet = Vec::new();

    packet.extend_from_slice(&moyu::protocol::MAGIC);
    packet.extend_from_slice(b"ZerAx");
    packet.resize(moyu::HEADER_LENGTH, 0);
    packet[moyu::HEADER_LENGTH - 1] = 0;

    packet.extend_from_slice(b"Hello, World!");

    let m = moyu::Packet::try_from(&*packet).unwrap();

    println!("user_name: {}\nop: {:?}\nmsg: {}", m.get_user_name(), m.get_op(), m.get_message());
}
